﻿import com.dmotiko.akira.*
import com.dmotiko.general.*

class PortfolioMainButtons
extends BaseClip {
	
	private var data:Object;
	private var txtLabel:TextField;
	private var mcAppear:MovieClip;
	private var mcThumbsAppear:MovieClip;
	
	function PortfolioMainButtons(){
		mcAppear = this.createEmptyMovieClip("mcAppear", this.getNextHighestDepth());
		mcThumbsAppear = this.createEmptyMovieClip("mcThumbsAppear", this.getNextHighestDepth());
	}
	
	public function childLoaded(child:MovieClip):Void{
			
		var nTimer:Number = getTimer();
		var root:MovieClip = this;
		mcThumbsAppear.onEnterFrame = function(){
			if(getTimer() - nTimer > 350){
				delete this.onEnterFrame;
				for(var i=0; i < 8; i++){
					if(!root.data.photos[i]) break;
					root["mcThumb"+(i+1)].setDelay(i*150);
					root["mcThumb"+(i+1)].setData(root.data.photos[i]);
				}
			}
		}
	}
	public function childChanged(child:MovieClip):Void{
		AkiraApp.getApp().showPhoto(child.getData());
	}
	
	public function setData(data):Void {
		this.data = data;
		refresh();		
	}
	
	public function getData():Object {
		return this.data;
	}
	
	private function refresh(){
		var sLabel:String = data.name.toUpperCase();
		var txtLabel = this.txtLabel;
		mcAppear.onEnterFrame = function(){
			
			if(txtLabel.text.length == sLabel.length){
				delete this.onEnterFrame;
			} else {
				txtLabel.text = sLabel.substr(0, txtLabel.text.length + 1);
			}
		}
				
	}
	
}